<script lang="ts" setup>
  import { computed, onMounted, ref } from 'vue';
  import { useUserStore } from '@/store';
  import { Menus } from '@/store/modules/user/types';

  const userStore = useUserStore();
  const data = ref();
  const userInfo = computed(() => {
    return {
      name: userStore.name,
    };
  });
  onMounted(async () => {
    await userStore.info();

    const d = [
      {
        label: '用户名',
        value: userStore.name,
      },
      {
        label: '手机号',
        value: userStore.phone,
      },
      {
        label: '邮箱',
        value: userStore.email,
      },
      {
        label: '角色',
        value: userStore.role ? userStore.role.join(',') : '-',
      },
      {
        label: '菜单',
        value: userStore.menus
          ? userStore.menus.map((menu: any) => menu.name).join(', ')
          : '-',
      },
    ];
    data.value = d;
  });
</script>

<template>
  <div>
    <a-col class="banner">
      <a-col :span="8">
        <a-typography-title :heading="5" style="margin-top: 0">
          {{ $t('workplace.welcome') }} {{ userInfo.name }}
        </a-typography-title>
      </a-col>
      <a-divider class="panel-border" />

      <a-space direction="vertical" size="large" fill>
        <a-descriptions :data="data" size="large" title="用户信息" bordered />
      </a-space>
    </a-col>
  </div>
</template>

<style scoped lang="less">
  .banner {
    width: 100%;
    padding: 20px 20px 0 20px;
    background-color: var(--color-bg-2);
    border-radius: 4px 4px 0 0;
  }

  :deep(.arco-icon-home) {
    margin-right: 6px;
  }
</style>
